/**
 * @filename:SuppliterServiceImpl 2021-11-04 01:53:18
 * @project com/lwl/blue  V1.0
 * Copyright(c) 2018 <a href=mailto:lanwenliang@yidianlife.com>蓝文良</a> Co. Ltd. 
 * All right reserved. 
 */
package com.lwl.blue.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lwl.blue.commont.base.JsonResult;
import com.lwl.blue.commont.base.PageParam;
import com.lwl.blue.commont.utils.ExcelUtil;
import com.lwl.blue.dao.SupplierDao;
import com.lwl.blue.entity.Supplier;
import com.lwl.blue.service.SupplierService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**   
 * <p>自定义serviceImpl写在这里</p>
 * 
 * <p>说明： 服务实现层</P>
 * @version: V1.0
 * @author: <a href=mailto:lanwenliang@yidianlife.com>蓝文良</a>
 * 
 */
@Service
class SupplierServiceImpl extends ServiceImpl<SupplierDao, Supplier> implements SupplierService {
    @Resource
    private SupplierDao supplierDao;
    @Override
    public JsonResult<Page<Supplier>> pages(PageParam<Supplier> pageParam) {
        Page<Supplier> page = new Page<>(pageParam.getPageNum(), pageParam.getPageSize());
        return new JsonResult<Page<Supplier>>().success(supplierDao.pages(page, pageParam.getParam()));

    }

    @Override
    public JsonResult export(MultipartFile file) {
        List<Supplier> list = ExcelUtil.importExcel(file, Supplier.class);
        int count = 0;
        if (list == null || list.size() < 0) {
            return new JsonResult().error("微信核销数据导入数据为空");
        }
        for (Supplier w : list) {
            try {
//                Supplier wxVerification = changePojo(w);
//                wxVerification(wxVerification);
                count++;
            } catch (Exception ex) {
//                log.error("【微信核销数据导入】异常：{}{}", ex, ex.getMessage());
            }
        }
        return new JsonResult().success("导入成功：" + count + "条");
    }
}